﻿namespace WPForms.Phone.Model
{
    using System;
    using System.Collections.Generic;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;

    /// <summary>
    /// Stores on file/directory entry found on the skydrive
    /// </summary>
    public class EntryResult
    {
        /// <summary>
        /// Reference to the image source converter.
        /// </summary>
        private static ImageSourceConverter imageSourceConverter = new ImageSourceConverter();

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets the id.
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// Gets or sets the children.
        /// </summary>
        public List<EntryResult> Children { get; set; }

        /// <summary>
        /// Gets or sets the parent.
        /// </summary>
        public EntryResult Parent { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is directory.
        /// </summary>
        /// <value>
        /// <c>true</c> if this instance is directory; otherwise, <c>false</c>.
        /// </value>
        public bool IsDirectory { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is file.
        /// </summary>
        /// <value>
        /// <c>true</c> if this instance is file; otherwise, <c>false</c>.
        /// </value>
        public bool IsFile { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is enabled.
        /// </summary>
        /// <value>
        /// <c>true</c> if this instance is enabled; otherwise, <c>false</c>.
        /// </value>
        public bool IsEnabled { get; set; }

        /// <summary>
        /// Gets the image source for the icon associated with this item.
        /// </summary>
        public object IconSource
        {
            get
            {
                if (this.IsDirectory)
                {
                    return imageSourceConverter.ConvertFromString("/WPForms.Phone;component/Resources/Images/folder.png");
                }
                else
                {
                    return imageSourceConverter.ConvertFromString("/WPForms.Phone;component/Resources/Images/file.png");
                }
            }
        }

        /// <summary>
        /// Gets the image source for the icon associated with this item's action.
        /// </summary>
        public object ActionIconSource
        {
            get
            {
                if (this.Name.EndsWith(".sdf"))
                {
                    return imageSourceConverter.ConvertFromString("/WPForms.Phone;component/Resources/Images/data_backup.png");
                }
                else if (this.IsDirectory)
                {
                    return imageSourceConverter.ConvertFromString("/WPForms.Phone;component/Resources/Images/next.png");
                }

                return imageSourceConverter.ConvertFromString("/WPForms.Phone;component/Resources/Images/noentry.png");
            }
        }
    }
}
